//package com.geeklan.smart.data.remote.mqtt;
//
//import com.geeklan.smart.data.remote.mqtt.MqttConstant;
//
//import org.eclipse.paho.client.mqttv3.MqttClient;
//import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
//import org.eclipse.paho.client.mqttv3.MqttException;
//import org.eclipse.paho.client.mqttv3.MqttMessage;
//
//public class BaseMqttClient extends MqttClient {
//
//    public BaseMqttClient(String clientId) throws MqttException {
//        super(MqttConstant.URL, clientId, null);
//        MqttConnectOptions options = new MqttConnectOptions();
//        options.setCleanSession(true);//清除回话，说明是临时会话，如果自动重连之后，不会自动订阅
//        options.setKeepAliveInterval(60);
//        options.setAutomaticReconnect(true);  // 自动重连
//        connect(options);
//    }
//
//
//    public void publishMessage(String topic, String payload) throws MqttException {
//        MqttMessage message = new MqttMessage(payload.getBytes());
//        message.setQos(1);
//        publish(topic, message);
//    }
//
//    public void subscribeTopic(String topic, int qos) throws MqttException {
//        subscribe(topic, qos);
//    }
//
//}
